﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
namespace YKhoa_Lib.DAL
{
    public class DAL_DichVu : SqlConnectionRun
    {
        private List<SqlParameter> parameters = null;
        public DAL_DichVu()
        {
           
        }
        /// <summary>
        /// Load chi tiết các dịch vụ được chia theo mã khoa
        /// </summary>
        /// <returns></returns>
        public DataTable LoadChiTietDichVu(string _maKhoa, string _maNhom)
        {
            string sql = @"select dv.*, ''s1tendichvu,''s2tendichvu,''s3tendichvu,''s1madv,''s2madv,''s3madv 
                            from vienphi..dm_dichvu dv /*left join phongkham..view_xetnghiem xn on dv.madv=xn.idxetnghiem*/ 
                            where makhoa=@MaKhoa and hienthi = @HienThi";
            parameters = new List<SqlParameter>();
            parameters.Add(new SqlParameter("MaKhoa", _maKhoa));            
            parameters.Add(new SqlParameter("HienThi", 1));
            if (_maNhom != "")
            {
                sql += " and nhom=@MaNhom";
                parameters.Add(new SqlParameter("MaNhom", _maNhom));
            }            
            sql += " order by madv";
            DataTable dt = SqlExecuteQueryReader(sql, parameters);
            return dt;
        }

        public DataTable LoadNhomDichVu(string _maKhoa)
        {
            string sql = @"select distinct makhoa,nhom,tennhom from vienphi..dm_dichvu dm 
                            left join vienphi..dm_nhomdichvu ndv on dm.nhom=ndv.manhom 
                            where makhoa=@MaKhoa and not tennhom is null and nhom <> @MaNhom ";
            parameters = new List<SqlParameter>();
            parameters.Add(new SqlParameter("MaKhoa", _maKhoa));
            parameters.Add(new SqlParameter("MaNhom", "kham"));
            DataTable dt = SqlExecuteQueryReader(sql, parameters);
            return dt;
        }
    }
}